package com.hanbang.chu_xing_gao_zhao.view_public;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;

import com.hanbang.chu_xing_gao_zhao.base.BaseActivity;
import com.hanbang.chu_xing_gao_zhao.utils.MyToast;
import com.hanbang.chu_xing_gao_zhao.view_dynamic.DynamicActivity;
import com.hanbang.cxgz_2.R;

public class DynamicCommentActivity extends BaseActivity {
    /**
     * 编辑框
     */
    private EditText commentText;

    /**
     * 编辑框
     */
//	private TextView title;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dynamic_comment);

        initView();
        setOnClickListener();

    }

    /**
     * 初始化view
     */
    private void initView() {

        commentText = (EditText) findViewById(R.id.et_dynamic_comment);

    }

    /**
     * 设置点击事件
     */
    private void setOnClickListener() {
        // 发布添加监听
        ((TextView) findViewById(R.id.tv_bar_top_conver_classify_title3)).setOnClickListener(onClickListener);

        // 发布添加监听
        ((TextView) findViewById(R.id.tv_bar_top_conver_classify_title1)).setOnClickListener(onClickListener);

    }



    /**
     * 处理监听
     */
    @SuppressWarnings("unused")
    private OnClickListener onClickListener = new OnClickListener() {
        Intent intent = new Intent();

        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                // 发布
                case R.id.tv_bar_top_conver_classify_title3:

                    if (commentText.length() == 0) {
                        MyToast.show(DynamicCommentActivity.this, "评论内容不能为空", 1);
                        return;
                    } else if (commentText.length() > 200) {
                        MyToast.show(DynamicCommentActivity.this, "评论内容最多200字", 1);
                        return;
                    }

                    Intent intent = getIntent();
                    intent.putExtra("commentText", commentText.getText().toString());
                    intent.putExtra("position", intent.getIntExtra("position", -1));
                    intent.putExtra("feed_id", intent.getIntExtra("feed_id", -1));

                    setResult(RESULT_OK, intent);
                    finish();
                    break;
                // 发布
                case R.id.tv_bar_top_conver_classify_title1:
                    finish();
                    break;

                default:
                    break;
            }

        }

    };

    @Override
    protected void onResume() {

        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onDestroy() {

        super.onDestroy();

    }

}